<%@page contentType="text/html; charset=utf-8" language="java" errorPage="error.jsp"%>
<%@page import="com.greendragon.persistence.domain.User"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
String subtitle = "个人资料 - 后台管理";
String scripts = "/static/js/admin.js?v=0.0.1,/static/js/Validform_min.js";
String styles = "/static/css/admin.css?v=0.0.1,/static/css/validation.css?v=0.0.1";
%>
<%@ include file="/include/header.jspf"%>
<script>
$(document).ready(function() {
	new GD.admin.init("${uid==user.id?'profile':'account'}");
	$("#profile_info").Validform({
		btnSubmit:"#btn_sub",
		tiptype:function(msg,o,cssctl){
			if(o.obj){
					var objtip=o.obj.parent().parent().find(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
		},
		tipSweep:true,
		postonce:true
	});
	
	$("#changepw").Validform({
		btnSubmit:"#pw_sub",
		tiptype:function(msg,o,cssctl){
			if(o.obj){
					var objtip=o.obj.parent().parent().find(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
		},
		tipSweep:true,
		postonce:true
	});
});
</script>
<body>
  <div id="wrap">
<div id="content">
   <%@include file="include/body-header.jspf"%>
   <div id="bodier">
		<jsp:include page="include/adminmenu.jspf"/>
		<div id="body-content">
			<div id="content-wrap" class="profile">
				<c:if test="${param.updated=='true'}">
				<div id="setting-updated" class="radius5">账户信息已更新。</div>
				</c:if>
				<div class="icon32 account-icon"></div>
				<h2 class="title">资料</h2>
				<c:choose>
				   <c:when test="${null==name}"> 
						<div class="error-tip radius5 clear">没有找到符合条件的用户！</div>
				   </c:when>
				   <c:when test="${null!=errors.uid}"> 
				   <div class="error-tip radius5 clear">
						<c:forEach items="${errors.uid}" var="err">
							${err}
						</c:forEach>
					</div>
					<c:set var="uid"/>
				   </c:when>
				</c:choose>
				<c:if test="${null!=name}">
				<form id="profile_info" action="userUpdate.do" method="post" class="clear">
					<h3>个人信息${uid}</h3>
					<table class="form-table">
						<tbody>
						<tr>
							<th><label>用户名</label></th>
							<td class="input_content">
								<input class="regular-text radius5 gray" name="name" type="text"  value="${name}" readonly="true"/>
							</td>
							<td class="checktip"><div class="Validform_checktip gray">用户名无法更改</div></td>
						</tr>
						<tr>
							<th><label for="nickname">昵称<span class="gray"> (必填)</span></label></th>
							<td>
								<input id="nickname" class="regular-text radius5" name="nickname" type="text" value="${nickname}" datatype="s1-16" nullmsg="请输入昵称" errormsg="昵称最多12个字符"/>
							</td>
							<td>
							<c:choose>
							   <c:when test="${null!=errors.nickname}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.nickname}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">昵称最多12个字符</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
					</table>
					<h3>联系方式</h3>
					<table class="form-table">
						<tr>
							<th><label for="email">电子邮件</label></th>
							<td class="input_content">
								<input id="email" class="regular-text radius5" name="email" type="text" value="${email}" datatype="e" ignore="ignore" errormsg="请输入邮箱地址"/>
							</td>
							<td class="checktip">
							<c:choose>
							   <c:when test="${null!=errors.email}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.email}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">请输入常用的邮箱地址</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="web">网站</label></th>
							<td colspan="2">
								<input id="web" class="regular-text radius5" name="website" type="text" value="${website}"/>
							</td>
						</tr>
						<tr>
							<th ><label for="phone">固定电话</label></th>
							<td colspan="2">
								<input id="phone" class="regular-text radius5" name="phone" type="text" value="${phone}"/>
							</td>
						</tr>
						<tr>
							<th><label for="cellphone">手机号码</label></th>
							<td>
								<input id="cellphone" class="regular-text radius5" name="cellphone" type="text" value="${cellphone}" datatype="m" ignore="ignore" errormsg="请输入您的手机号码"/>
							</td>
							<td>
							<c:choose>
							   <c:when test="${null!=errors.cellphone}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.cellphone}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>
								<div class="Validform_checktip gray"></div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="qq">QQ</label></th>
							<td colspan="2">
								<input id="qq" class="regular-text radius5" name="qq" type="text" value="${qq}"/>
							</td>
						</tr>
					</table>
					<h3>密码保护问题</h3>
					<table class="form-table">
						<tr>
							<th><label for="question">问题</label></th>
							<td class="input_content">
								<select id="question" name="question" class="regular-text radius5">
									<option value="1"<c:if test="${securityQuestion=='1'}"> selected="selected"</c:if>>你和爱人第一次相识的地方在哪？</option>
									<option value="2"<c:if test="${securityQuestion=='2'}"> selected="selected"</c:if>>你最喜欢的一部电影的名字是什么？</option>
									<option value="3"<c:if test="${securityQuestion=='3'}"> selected="selected"</c:if>>你高中一年级班主任老师的名字是什么？</option>
									<option value="4"<c:if test="${securityQuestion=='4'}"> selected="selected"</c:if>>你最讨厌吃的食物是什么？</option>
									<option value="5"<c:if test="${securityQuestion=='5'}"> selected="selected"</c:if>>你书架上最右手边的一本书的名字是什么？</option>
									<option value="6"<c:if test="${securityQuestion=='6'}"> selected="selected"</c:if>>你从来没有吃过的一种食物是什么？</option>
									<option value="7"<c:if test="${securityQuestion=='7'}"> selected="selected"</c:if>>你中学同桌的名字是什么？</option>
								</select>
							</td>
							<td class="checktip">
							<c:choose>
							   <c:when test="${null!=errors.securityQuestion}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.securityQuestion}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="answer">答案</label></th>
							<td>
								<input id="answer" class="regular-text radius5" name="answer" type="text" value="${securityAnswer}" ignore="ignore" datatype="s4-20" errormsg="答案范围在4~20位之间"/>
							</td>
							<td>
							<c:choose>
							   <c:when test="${null!=errors.securityAnswer}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.securityAnswer}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   	<c:otherwise>  
								<div class="Validform_checktip gray">答案范围在4~20位之间</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="role">角色</label></th>
							<td colspan="2">
								<select id="role" name="role" class="regular-text radius5">
									<option value="user"<c:if test="${role=='user'}"> selected="selected"</c:if>>普通用户</option>
									<option value="admin"<c:if test="${role=='admin'}"> selected="selected"</c:if>>管理员</option>
								</select>
							</td>
						</tr>
					</table>
					<input type="hidden" name="uid" value="${uid}"/>
					<input id="btn_sub" type="submit" class="button-blue" value="保存更改">
				</form>
				<form id="changepw" class="left" action="changepw.do" method="post">
					<h3>修改密码</h3>
					<table class="form-table">
						<c:if test="${role!='user'}">
						<tr>
							<th><label for="oldpw">旧密码</label></th>
							<td>
								<input id="oldpw" class="regular-text radius5" name="oldpw" type="password" datatype="s6-20" nullmsg="请输入密码" errormsg="密码范围在6~20位之间，不能使用空格"/>
							</td>
							<td class="checktip">
							<c:choose>
							   <c:when test="${null!=errors.oldpw}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.oldpw}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
								<c:otherwise>  
								<div class="Validform_checktip gray">请输入旧密码</div>
							   </c:otherwise>
							</c:choose>
							</div>
						</tr>
						</c:if>
						<tr>
							<th><label for="password">新密码</label></th>
							<td>
								<input id="password" class="regular-text radius5" name="password" type="password" datatype="s6-20" nullmsg="请设置密码" errormsg="密码范围在6~20位之间，不能使用空格"/>
							</td>
							<td class="checktip">			
							<c:choose>
							   <c:when test="${null!=errors.password}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.password}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">密码范围在6~20位之间，不能使用空格</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="confirmpw">密码确认</label></th>
							<td>
								<input id="confirmpw" class="regular-text radius5" type="password" name="confirmPassword" datatype="*" recheck="password" errormsg="您两次输入的账号密码不一致"/>
							</td>
							<td>			
							<c:choose>
							   <c:when test="${null!=errors.confirmPassword}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.confirmPassword}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">两次输入密码须一致</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
					</table>
					<input type="hidden" name="uid" value="${uid}"/>
					<input id="pw_sub" type="submit" class="button-blue" value="保存更改">
				</form>
				</c:if>
			</div>
		</div>
		<div class="clear"></div>
	</div>
 </div>
 </div>
<%@include file="include/footer.jspf"%>